<template>
	<view class="currentPage">
		<topCard :userInfo='userInfo'></topCard>
		<functionList @changeInfo="confirm" :showView = 'showView' @showWebview= "showWebview" ref="fnList"></functionList>
		<buttonOperation @tapBtn='tapBtn' v-if="userInfo">
			<view class="btn_bottom">
				<image src="../../static/icon/my/exit.png" mode=""></image>
				<text>退出登录</text>
			</view>
		</buttonOperation>
		<!-- 占位符 -->
		<view style="height: 100upx;width: 100%;" v-if="userInfo">
		</view>
		<u-modal :show="show" :closeOnClickOverlay="true" :showCancelButton='true' :title="'提示'" @confirm='confirm'
			@cancel='cancel' :content="'是否退出登录？'" confirmColor="#2CB9A4"></u-modal>
	</view>
</template>

<script>
	import qrInfo from '@/components/my/qrInfo.vue'
	import functionList from '@/components/my/functionList.vue'
	import topCard from '@/components/my/topCard.vue'
	import buttonOperation from '@/components/common/buttonOperation.vue'
	import eventBUs from '../../utils/eventBus.js'
	export default {
		components: {
			qrInfo,
			topCard,
			buttonOperation,
			functionList
		},
		onShow() {
			this.showView = false
			let userInfo = uni.getStorageSync('userInfo')
			// console.log(userInfo,11)
			if(userInfo){
				this.$refs.fnList.getConfig()
			}
		},
		data() {
			
			return {
				showView:false,
				isLogin: false,
				// userInfo: {
				// 	avatar: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
				// 	nickname: '波比',
				// 	mobile: "18487301491"
				// },
				userInfo:null,
				show: false
			}
		},
		onShareAppMessage() {
			return {
				title: '',
				path: '/pages/my/my',

			}
		},
		onShareTimeline: function() {
			return {
				title: '',
				path: '/pages/my/my',
			}
		},
		onLoad(res) {
			// console.log(res,1111)
			let userInfo = uni.getStorageSync('userInfo')
			this.userInfo = userInfo
			this.$eventBus.$on('hasLogin', val => {
				if (val) this.isLogin = true
				let userInfo = uni.getStorageSync('userInfo')
				console.log(userInfo)
				this.userInfo = userInfo
			});
		},
		methods: {
			showWebview(){
				this.showView = true
			},
			tapBtn() {
				this.show = true
			},
			confirm() {
				uni.removeStorageSync('token')
				uni.removeStorageSync('userInfo')
				this.show = false
				this.userInfo = null
			},
			cancel() {
				this.show = false
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.currentPage {
		min-height: 100vh;
		background-color: #fff;
		overflow: hidden;
	}

	.btn_bottom {
		display: flex;
		justify-content: center;
		align-items: center;

		image {
			width: 30rpx;
			height: 30rpx;
			margin-right: 30rpx;
		}
	}

	.custom_style {
		color: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;

		&_icon {
			// background-color: #15357A;
			// background-image: url(../../static/tabble/tab2.png);
			font-size: 65rpx;
			width: 90rpx;
			height: 90rpx;
			border-radius: 100%;
			display: flex;
			background-repeat: no-repeat;
			background-size: 100%;
			justify-content: center;
			align-items: center;
			margin-top: -40rpx;
		}
	}
</style>